/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DDK 1.10.00.23 07-02-03 (ddk-b12)" */
/*
 *  ======== async.h ========
 *
 *  This file defines the async macros to GIO.
 *
 *   ASYNC_abort
 *   ASYNC_control
 *   ASYNC_create
 *   ASYNC_delete
 *   ASYNC_flush
 *   ASYNC_read
 *   ASYNC_write
 *
 */

#ifndef ASYNC_
#define ASYNC_

#include <gio.h>
#include <iom.h>


#ifdef __cplusplus
extern "C" {
#endif


/*
 *  ======== ASYNC_abort ========
 *  Abort all input and output.  ASYNC_abort() is a synchronous call and only 
 *  returns when all I/O has been successfully aborted.
 */
#define ASYNC_abort(gioChan) \
        GIO_abort(gioChan)


/*
 *  ======== ASYNC_control ========
 *  This is a direct call down into the mini driver.
 */
#define ASYNC_control(gioChan, cmd, args) \
        GIO_control(gioChan, cmd, args)

/*
 *  ======== ASYNC_create ========
 *  ASYNC_create() allocates and initializes an GIO_Obj structure. ASYNC_create
 *  returns a non-NULL GIO_Handle object on success and NULL for failure.
 *  The 'name' parameter is used to find a matching name in the device
 *  table.  Associated IOM_Fxns table and params structure are then used
 *  to create a channel for that device.   The 'attrs->nPackets' parameter
 *  specifies the number of asynchronous I/O calls that can be outstanding.
 *  The status field is the address where a device status is returned, ignored
 *  if status is specified as NULL.
 */
#define  ASYNC_create(name, mode, status, optArgs, attrs) \
        GIO_create(name, mode, status, optArgs, attrs)


/*
 *  ======== ASYNC_delete ========
 *  ASYNC_delete() frees up channel resources.
 */
#define ASYNC_delete(giochan) \
        GIO_delete(gioChan)

/*
 *  ======== ASYNC_flush ========
 *  Flush all input and output.  Flush drains all output buffers and discards
 *  any pending input.  ASYNC_flush() is synchronous and only returns when
 *  all I/O has been successfully flushed.
 */
#define ASYNC_flush(gioChan) \
        GIO_flush(gioChan)


/*
 *  ======== ASYNC_read ========
 *  Asynchronous read command.  ASYNC_read() returns 'IOM_PENDING' if
 *  I/O was successfully queued and 'IOM_COMPLETED' if I/O was able to
 *  complete immediately.
 */
#define ASYNC_read(gioChan, bufp, psize, appCallback) \
        GIO_submit(gioChan, IOM_READ, bufp, psize, appCallback)


/*
 *  ======== ASYNC_write ========
 *  Asynchronous write command.  Same semantics as ASYNC_read() above.
 */
#define ASYNC_write(gioChan, bufp, psize, appCallback) \
        GIO_submit(gioChan, IOM_WRITE, bufp, psize, appCallback)



#ifdef __cplusplus
}
#endif /* extern "C" */

#endif /* ASYNC_ */
